package com.sea.supply.mapper;

import com.sea.supply.entity.ProduceDetail;
import org.apache.ibatis.annotations.Param;

import java.util.List;


/**
 *  采购单接口
 * @author 陈鸿飞
 * <br/>
 */
public interface ProduceDetailMapper {
    /**
     * 新增
     * @param produceDetail
     * @return
     */
    int insert(ProduceDetail produceDetail);

    /**
     * 查询采购单明细
     * @param produceId
     * @return
     */
    List<ProduceDetail> findByProduceId(Integer produceId);

    /**
     * 更新明细数据
     * @param produceDetail
     * @return
     */
    int update(ProduceDetail produceDetail);

    /**
     * 查找可收货数量
     * @param receivePo
     * @param receiveSku
     * @return
     */
    List<ProduceDetail> findReceiveNumber(@Param("receivePo")String receivePo,
                                          @Param("receiveSku")String receiveSku,
                                          @Param("channelName")String channelName,
                                          @Param("receiveDate")String receiveDate);

    /**
     * 收货完成
     * @param id
     * @return
     */
    int updateReceiveNumber(Integer id);

    /**
     * 查询可收获数量
     * @param produceId
     * @return
     */
    int findReceive(Integer produceId);

    /**
     * 导出明细
     * @param idList
     * @return
     */
    List<ProduceDetail> exportProduceDetail(Integer[] idList);

    /**
     * 更新占有量
     * @param useNumber
     * @param id
     * @return
     */
    int updateUseNumber(@Param("useNumber")Integer useNumber,@Param("id")Integer id);

    /**
     * 条件查询
     * @param orderSku
     * @param orderChannelName
     * @param orderDate
     * @param producePo
     * @return
     */
    ProduceDetail getIdByCnd(@Param("orderSku")String orderSku,
                             @Param("orderChannelName")String orderChannelName,
                             @Param("orderDate")String orderDate,
                             @Param("producePo")String producePo);

    /**
     * 导入国内仓分配
     * @param orderSku
     * @param orderChannelName
     * @param orderDate
     * @param producePo
     * @return
     */
    ProduceDetail getWareDistribute(@Param("orderSku")String orderSku,
                                    @Param("orderChannelName")String orderChannelName,
                                    @Param("orderDate")String orderDate,
                                    @Param("producePo")String producePo);

    /**
     * 根据ID查找
     * @param id
     * @return
     */
    ProduceDetail findById(Integer id);


    /**
     * 更新剩余量
     * @param receiveNumber
     * @param id
     * @return
     */
    Integer updateSurplusNumber(@Param("receiveNumber")Integer receiveNumber,@Param("id")Integer id);

    /**
     * 更新短装数量
     * @param produceDetail
     * @return
     */
    Integer updateShort(ProduceDetail produceDetail);


    Integer findByFirstProduce(@Param("orderSku")String orderSku,@Param("supplierName")String supplierName);

    Integer updateReadyUseNumber(@Param("useReadyNumber")Integer useReadyNumber,@Param("id")Integer id);


}